(function (vc) {
    vc.extends({
        propTypes: {
            emitChooseInoutOrder: vc.propTypes.string,
            emitLoadData: vc.propTypes.string
        },
        data: {
            chooseInoutOrderInfo: {
                inoutOrders: [],
                orderId: '',
                state: '',
                prodNameLike:'',
                personNameLike:'',
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('chooseInoutOrder', 'openChooseInoutOrderModel', function (_param) {
                $('#chooseInoutOrderModel').modal('show');
                if (_param.hasOwnProperty("state")) {
                    $that.chooseInoutOrderInfo.state = _param.state;
                }
                $that._refreshChooseInoutOrderInfo();
                $that._loadAllProductInfo(1, 10);
            });
            vc.on('chooseInoutOrder', 'paginationPlus', 'page_event',
                function (_currentPage) {
                    $that._loadAllProductInfo(_currentPage, 10);
                });
        },
        methods: {
            _loadAllProductInfo: function (_page, _row) {
                let param = {
                    params: {
                        page: _page,
                        row: _row,
                        orderId: $that.chooseInoutOrderInfo.orderId,
                        personNameLike: $that.chooseInoutOrderInfo.personNameLike,
                        prodNameLike: $that.chooseInoutOrderInfo.prodNameLike,
                        state: $that.chooseInoutOrderInfo.state,
                        shopId: vc.getCurrentCommunity().shopId,
                        orderType: '10000'
                    }
                };
                //发送get请求
                vc.http.apiGet('/inoutOrder/queryInoutOrder',
                    param,
                    function (json) {
                        let _json = JSON.parse(json);
                        $that.chooseInoutOrderInfo.inoutOrders = _json.data;
                        vc.emit('chooseInoutOrder', 'paginationPlus', 'init', {
                            total: _json.records,
                            dataCount: _json.total,
                            currentPage: _page
                        });
                    }, function () {
                        console.log('请求失败处理');
                    }
                );
            },
            chooseInoutOrder: function (_product) {
                if (_product.hasOwnProperty('name')) {
                    _product.productName = _product.name;
                }
                vc.emit($props.emitChooseInoutOrder, 'chooseInoutOrder', _product);
                vc.emit($props.emitLoadData, 'listProductData', {
                    productId: _product.productId
                });
                $('#chooseInoutOrderModel').modal('hide');
            },
            queryProducts: function () {
                $that._loadAllProductInfo(1, 10);
            },
            _refreshChooseInoutOrderInfo: function () {
                $that.chooseInoutOrderInfo.orderId = "";
                $that.chooseInoutOrderInfo.prodNameLike = "";
                $that.chooseInoutOrderInfo.personNameLike = "";
            }
        }
    });
})(window.vc);
